#ifndef INPUTTEXT_H
#define INPUTTEXT_H

//#define LOG_TIME

#include <QDialog>
#include <vector>
#include <chrono>
#include "padgraphicsview.h"
#include "wordpredictor.h"

#ifdef LOG_TIME
    #include <QTimer>
#endif



namespace Ui {
class InputText;
}



class InputText : public QDialog
{
    Q_OBJECT

public:
    explicit InputText(QWidget *parent = nullptr);
    ~InputText();

protected:
    Ui::InputText *ui;

    std::chrono::high_resolution_clock::time_point startClockTime;

    static const size_t max_text_len = 10000;
    static const size_t max_sentence = 502;
    char text[max_text_len];
    int senIndex;
    int senWordIndex;
    double passedSecs;

    bool hasStartTime;

    std::vector<int> senWordNum;
    std::vector<std::string> sentences;
    std::vector<std::string> words;
    size_t wordNum, wordIndex, lastWordIndex, charIndex, totalChar, curChar;
    std::string underStr;
    PadGraphicsView *m_view;
    WordPredictor *wordPredictor;

    void initText();
    void showWords();
    void updateChar();
    int getFontSize();

    FILE* outputFile;


    QTimer *timeCounter;

#ifdef LOG_TIME

    QTimer *m_timer;

#endif

protected slots:
    void highLightWord(int index);
    void updateCandidateWords();
    void inputOneWord();
    void startTimeCounter();
    void stopTimeCounter();
    void updateTimeLabel();

#ifdef LOG_TIME
    void logTime();
#endif

public slots:


};

#endif // INPUTTEXT_H
